 <!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>{$Think.config.site.title} - 库存管理</title>

    <meta name="keywords" content="{$Think.config.site.keywords}">

    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.min.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.min.css?v=4.0.0" rel="stylesheet">

</head>
<style>
#listtable .fa{
	cursor:pointer;
	color:#1ab394;
	margin-right:1em;
}
th .tag{font-size: 12px; color: #e66c6c; font-weight: normal;}
.ibox-title .tag{font-size: 12px; color: #e66c6c; font-weight: normal; display: inline-block; margin-left: 20px;}
.specval-hide{display: none;}
.detail{background: #f1f1f1;}
</style>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
      <div class="row">
            <div class="col-sm-4">
                <div id="nestable-menu">
                	<!-- <button data-action="addGoods" data-href='{:url("addGoods",'',false)}' type="button" class="btn btn-primary btn-sm "><i class="fa fa-plus"></i> 发布商品</button>
                    <button type="button" class="btn btn-white btn-sm openall">展开 / 收起</button> -->
                </div>
            </div>
      </div>
      <div class="row">
          <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>商品列表</h5>
						<span class="text-danger m-l-sm">说明: 点击商品名称可查看明细</span>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                        	<!-- <div class="col-sm-6">
								<span class="btn btn-primary m-l"></span> 采购入库
								<span class="btn btn-success m-l"></span> 配送出库
								<span class="btn btn-warning m-l"></span> 退单入库
								<span class="btn btn-danger m-l"></span> 退货出库
								<span class="btn btn-info m-l"></span> 手动入库
						</div> -->
                          	<div class="col-sm-12">
                                <div class="input-group pull-right">
                                <form action="{:url('index')}" method="get" enctype="application/x-www-form-urlencoded">
                                <div class="input-group">
                                    <input type="text" placeholder="请输入关键词" class="input-sm form-control" value="{$Think.get.keywords ?? ''}" name="keywords">
                                    <input type="hidden" class="lastent_time" name="lastent_time" value="">
                                    <span class="input-group-btn">
                                        <button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                </div>
                                </form>
                                </div>
                            </div>
                            
                        </div>
                        <div class="table-responsive">
                            <table class="table" id="listtable">
                                <thead>
                                    <tr>
                                        <th width="30"><input name="checkall" id="checkall"  type="checkbox" class="i-checks" value="1"></th>
                                        <th width="100">商品图片</th>
                                        <th width="">商品名称</th>
                                        <th width="200">库存数量</th>
                                        <th width="200">最近入库价</th>
                                        <th width="200" class="lastent_time_sort" data-lastent_time_sort='{$sort}'>最近入库时间 {if condition='$sort eq "lastent_time desc"'}<span>&darr;</span>{else /}<span>&uarr;</span>{/if}</th>
                                    </tr>
                                </thead>
                                <tbody>

                                	{volist name="list" id="vo"}
                                    <tr data-id="{$vo.specval_id}" data-type="goods" data-stock_id='{$vo.stock_id}' class="goodsname">
                                        <td>
                                            <input name="ids[]"  type="checkbox" class="i-checks" value="{$vo.goods_id}">
                                        </td>
                                        <td><img src="{$vo.picture}" width="30" height="30"></td>
                                        <td>{if condition="$vo.brand_name!=''"}（{$vo.brand_name}）{/if}{$vo.goods_name}【{$vo.specval_name}】</td>
                                        <td data-field="stock_num" class="jedit">{$vo.stock_num}</td>
                                        <td data-field="lastent_price" class="jedit">{$vo.lastent_price}</td>
                                        <td>{$vo.lastent_time}</td>
										<td></td>
                                    </tr>
									{volist name="vo['detail']" id="v"}
										<tr class="specval-{$v.specval_id} hidden detail">
											<td></td>
											<td>
												{switch name="v['type']"}
												    {case value="-10"}<span class="btn btn-danger btn-xs">退货出库</span>{/case}
												    {case value="-1"}<span class="btn btn-success btn-xs">配送出库</span>{/case}
												    {case value="1"}<span class="btn btn-primary btn-xs">采购入库</span>{/case}
												    {case value="10"}<span class="btn btn-warning btn-xs">退单入库</span>{/case}
												    {case value="2"}<span class="btn btn-info btn-xs">手动入库</span>{/case}
												{/switch}
											</td>
											<td>{$v.time}</td>
											<td>数量: {$v.num}</td>
											<td>价格: {$v.price}</td>
											<td>操作员: {$v.uname}</td>
											<td>{if($v.remark)}备注: {$v.remark}{else/}{/if} </td>
										</tr>
									{/volist}
                                   {/volist}
                                </tbody>
                            </table>
                        </div>
                        <div>{$list->render()}</div>
                    </div>
                </div>
            </div>

        </div>
    </div>

    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/peity/jquery.peity.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/iCheck/icheck.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
    <script src="{$Think.config.site.common_resource_url}js/majax.js"></script>
    <script src="{$Think.config.site.common_resource_url}js/jedit.js"></script>
</body>

</html>
<script>
    //切换排序
    $('.lastent_time_sort').click(function(){
        var lastent_time_sort = $(this).data('lastent_time_sort');
        if(lastent_time_sort == "lastent_time desc"){
            $('.lastent_time').val("lastent_time asc");
        }else{
            $('.lastent_time').val("lastent_time desc");
        }
        $('form').submit();
    })

    $(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});

    //全选
    $("#checkall").bind("ifChecked",function(){
        $("input[name='ids[]']").iCheck("check");
    });
    //取消全选
    $("#checkall").bind("ifUnchecked",function(){
        $("input[name='ids[]']").iCheck("uncheck");
    });
	
	$('.goodsname').click(function () {
		var id = $(this).data('id');
		$('.specval-' + id).toggleClass('hidden');
	})

    // $('.jedit').jedit({
    //     class:'inpbox',
    //     inputclass:'input-sm form-control',
    //     change:function(n,old){
    //         var self = this,tr=$(self).closest('tr'), stock_id=tr.data('stock_id'),field=$(this).data('field')
    //         if (isNaN(n)) {layer.msg('请填写数字',{icon: 2});$(self).text(old); return false;} 
    //         if (n<0) {layer.msg('请填写正数',{icon: 2});$(self).text(old); return false;}
            
    //         majax('{:url("quickedit")}',{stock_id:stock_id,field:field,value:n},function(d){
    //             if (d.code>0) {
    //                 $(self).text(n);
    //             }else{
    //                 $(self).text(old);
    //             }
    //         })
    //     }
    // });
</script>